//
//  MyPublicOrderStatusCell.m
//  PropertyMananger
//
//  Created by bh on 17/2/9.
//  Copyright © 2017年 BH. All rights reserved.
//

#import "MyPublicOrderStatusCell.h"

@implementation MyPublicOrderStatusCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *cellID = @"MyPublicOrderStatusCellID";
    MyPublicOrderStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(cell == nil) {
        cell = [[MyPublicOrderStatusCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    //选中cell的颜色 -无色
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
    
    
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        
        float  w  = BHscreenW - 60;
        
        //进入条
        self.progressView = [[UIProgressView alloc] init];
        self.progressView.progress = 0.0;
        self.progressView.trackTintColor = BHColor(204, 204, 204);
        self.progressView.progressTintColor = BHColor(215, 152, 2);
        [self.contentView addSubview:self.progressView];
        [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_offset(2);
            make.bottom.mas_offset(-25);
            make.centerX.equalTo(self.contentView);
            make.width.mas_offset(w);
        }];
        
        //节点
        UIImageView * leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ico_repair_state_onselected"]];
        [self.contentView addSubview:leftView];
        
        [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.progressView);
            make.centerX.equalTo(self.progressView.mas_left).offset(0);
        }];
        
        //待处理
        self.acceptView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_repair_state_onselected"]];
        [self.contentView addSubview:self.acceptView];
        [self.acceptView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.progressView.mas_left);
            make.bottom.equalTo(leftView.mas_top).offset(-5);
            make.size.mas_equalTo(CGSizeMake(40, 30));
        }];
        
        
        UILabel * pendingLabel = [[UILabel alloc]init];
        [self.acceptView addSubview:pendingLabel];
        pendingLabel.text = @"待处理";
        
        pendingLabel.textColor = BHColor(255, 255, 255);
        pendingLabel.font = BHFont(10);
        pendingLabel.textAlignment = NSTextAlignmentCenter;
        
        [pendingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.acceptView).with.offset(0);
            make.centerY.equalTo(self.acceptView).with.offset(-5);
            make.size.mas_equalTo(CGSizeMake(40, 20));
        }];
        
        
        //处理中
        self.inTreatmentView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_repair_state_onselected"]];
        // self.repairingView.hidden = YES;
        [self.contentView addSubview:self.inTreatmentView];
        [self.inTreatmentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.acceptView.mas_centerX).offset(w/4.0);
            make.centerY.equalTo(self.acceptView);
            make.size.mas_equalTo(CGSizeMake(40, 30));
        }];
        
        //处理中
        UILabel * inTreatmentLabel = [[UILabel alloc]init];
        [self.inTreatmentView addSubview:inTreatmentLabel];
        inTreatmentLabel.text = @"处理中";
        
        inTreatmentLabel.textColor = BHColor(255, 255, 255);
        inTreatmentLabel.font = BHFont(10);
        inTreatmentLabel.textAlignment = NSTextAlignmentCenter;
        
        [inTreatmentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.inTreatmentView).with.offset(0);
            make.centerY.equalTo(self.inTreatmentView).with.offset(-5);
            make.size.mas_equalTo(CGSizeMake(40, 20));
        }];
        
        //节点
        self.repairPointView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ico_repair_state_onselected"]];
        //   self.repairView.hidden = YES;
        [self.contentView addSubview:self.repairPointView];
        [self.repairPointView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.inTreatmentView);
            make.centerY.equalTo(self.progressView);
        }];
        
        //已处理
        self.handledView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_repair_state_onselected"]];
        //  self.handledView.hidden = YES;
        [self.contentView addSubview:self.handledView];
        [self.handledView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.inTreatmentView.mas_centerX).offset(w/4.0);
            make.centerY.equalTo(self.inTreatmentView);
            make.size.mas_equalTo(CGSizeMake(40, 30));
        }];
        
        UILabel * handledLabel = [[UILabel alloc]init];
        [self.handledView addSubview:handledLabel];
        handledLabel.text = @"已处理";
        
        handledLabel.textColor = BHColor(255, 255, 255);
        handledLabel.font = BHFont(10);
        handledLabel.textAlignment = NSTextAlignmentCenter;
        
        [handledLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.handledView).with.offset(0);
            make.centerY.equalTo(self.handledView).with.offset(-5);
            make.size.mas_equalTo(CGSizeMake(40, 20));
        }];
        
        self.handledPointView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ico_repair_state_onselected"]];
        //   self.handledPointView.hidden = YES;
        [self.contentView addSubview:self.handledPointView];
        [self.handledPointView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.handledView);
            make.centerY.equalTo(self.progressView);
            
        }];
        
        //回访
        self.callbackView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_repair_state_onselected"]];
        //  self.handledView.hidden = YES;
        [self.contentView addSubview:self.callbackView];
        [self.callbackView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.handledView.mas_centerX).offset(w/4.0);
            make.centerY.equalTo(self.handledView);
            make.size.mas_equalTo(CGSizeMake(40, 30));
        }];
        
        UILabel * callBackLabel = [[UILabel alloc]init];
        [self.callbackView addSubview:callBackLabel];
        callBackLabel.text = @"已回访";
        
        callBackLabel.textColor = BHColor(255, 255, 255);
        callBackLabel.font = BHFont(10);
        callBackLabel.textAlignment = NSTextAlignmentCenter;
        
        [callBackLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.callbackView).with.offset(0);
            make.centerY.equalTo(self.callbackView).with.offset(-5);
            make.size.mas_equalTo(CGSizeMake(40, 20));
        }];
        
        self.callbackPointView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ico_repair_state_onselected"]];
        //   self.handledPointView.hidden = YES;
        [self.contentView addSubview:self.callbackPointView];
        [self.callbackPointView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.callbackView);
            make.centerY.equalTo(self.progressView);
            
        }];
        
        
        //完成
        self.completeView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_repair_state_onselected"]];
        // self.completeView.hidden = YES;
        [self.contentView addSubview:self.completeView];
        [self.completeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.progressView.mas_right).offset(5);
            make.centerY.equalTo(self.acceptView);
            make.size.mas_equalTo(CGSizeMake(40, 30));
        }];
        
        UILabel * completeLabel = [[UILabel alloc]init];
        [self.completeView addSubview:completeLabel];
        completeLabel.text = @"完成";
        
        completeLabel.textColor = BHColor(255, 255, 255);
        completeLabel.font = BHFont(10);
        completeLabel.textAlignment = NSTextAlignmentCenter;
        
        [completeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.completeView).with.offset(0);
            make.centerY.equalTo(self.completeView).with.offset(-5);
            make.size.mas_equalTo(CGSizeMake(40, 20));
        }];
        
        self.rightView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ico_repair_state_onselected"]];
        [self.contentView addSubview:self.rightView];
        [self.rightView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.progressView);
            make.left.equalTo(self.progressView.mas_right).offset(0);
        }];
        
    }
    return self;
}
-(void)setProcessState:(NSString *)processState{
    _processState = processState;
    if([processState isEqualToString:@"10"]){//待处理
        self.progressView.progress = 0.0;
        self.inTreatmentView.image = IMG(@"bg_repair_state_unselected");//处理中
        self.repairPointView.image = IMG(@"ico_repair_state_unselected");
        
        self.handledView.image = IMG(@"bg_repair_state_unselected");//已处理
        self.handledPointView.image = IMG(@"ico_repair_state_unselected");
        
        self.callbackView.image = IMG(@"bg_repair_state_unselected");//回访
        self.callbackPointView.image = IMG(@"ico_repair_state_unselected");
        
        self.completeView.image = IMG(@"bg_repair_state_unselected");//完成
        self.rightView.image = IMG(@"ico_repair_state_unselected");
        
        
    }else if ([processState isEqualToString:@"30"]){//正在处理
        self.progressView.progress = 1.0/4.0;
        
        self.inTreatmentView.image = IMG(@"bg_repair_state_onselected");//处理中
        self.repairPointView.image = IMG(@"ico_repair_state_onselected");
        
        self.handledView.image = IMG(@"bg_repair_state_unselected");//已处理
        self.handledPointView.image = IMG(@"ico_repair_state_unselected");
        
        self.callbackView.image = IMG(@"bg_repair_state_unselected");//回访
        self.callbackPointView.image = IMG(@"ico_repair_state_unselected");
        
        self.completeView.image = IMG(@"bg_repair_state_unselected");//完成
        self.rightView.image = IMG(@"ico_repair_state_unselected");
        
        
        
    }else if ([processState isEqualToString:@"100"]){//已处理
        self.progressView.progress = 2.0/4.0;
        
        self.inTreatmentView.image = IMG(@"bg_repair_state_onselected");//处理中
        self.repairPointView.image = IMG(@"ico_repair_state_onselected");
        
        self.handledView.image = IMG(@"bg_repair_state_onselected");//已处理
        self.handledPointView.image = IMG(@"ico_repair_state_onselected");
        
        self.callbackView.image = IMG(@"bg_repair_state_unselected");//回访
        self.callbackPointView.image = IMG(@"ico_repair_state_unselected");
        
        self.completeView.image = IMG(@"bg_repair_state_unselected");//完成
        self.rightView.image = IMG(@"ico_repair_state_unselected");
        
        
    }else if ([processState isEqualToString:@"40"]){//回访
        self.progressView.progress = 3.0/4.0;
        
        self.inTreatmentView.image = IMG(@"bg_repair_state_onselected");//处理中
        self.repairPointView.image = IMG(@"ico_repair_state_onselected");
        
        self.handledView.image = IMG(@"bg_repair_state_onselected");//已处理
        self.handledPointView.image = IMG(@"ico_repair_state_onselected");
        
        self.callbackView.image = IMG(@"bg_repair_state_onselected");//回访
        self.callbackPointView.image = IMG(@"ico_repair_state_onselected");
        
        self.completeView.image = IMG(@"bg_repair_state_unselected");//完成
        self.rightView.image = IMG(@"ico_repair_state_unselected");
        
    }else if ([processState isEqualToString:@"50"]){
        
        self.progressView.progress = 1.0;
        
        self.inTreatmentView.image = IMG(@"bg_repair_state_onselected");//处理中
        self.repairPointView.image = IMG(@"ico_repair_state_onselected");
        
        self.handledView.image = IMG(@"bg_repair_state_onselected");//已处理
        self.handledPointView.image = IMG(@"ico_repair_state_onselected");
        
        self.callbackView.image = IMG(@"bg_repair_state_onselected");//回访
        self.callbackPointView.image = IMG(@"ico_repair_state_onselected");
        
        self.completeView.image = IMG(@"bg_repair_state_onselected");//完成
        self.rightView.image = IMG(@"ico_repair_state_onselected");
    }
    
}

-(void)setFrame:(CGRect)frame{
    frame.size.height -= 1;
    [super setFrame:frame];
}

@end
